package cn.net.xyan.easy.spring.core.config;

import cn.net.xyan.easy.spring.core.config.value.*;
import cn.net.xyan.easy.spring.core.utils.JsonHelper;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Collections;

/**
 * Created by xiashenpin on 16/1/16.
 */
public interface IAutoConfigManager {

    String RootApplicationContextConfigClass = "RootApplicationContextConfigClass";
    String MVCApplicationContextConfigClass = "MVCApplicationContextConfigClass";

    String RepositoryScanPackages = "RepositoryScanPackages";

    String EntityScanPackages = "EntityScanPackages";

    String MaxRequestSize = "MaxRequestSize";

    String ObjectMapperRef = "ObjectMapper";

    String DBConfigFile = "DBConfigFile";

    String EnableSecuritySupport = "EnableSecuritySupport";

    String EntityManagerInViewFilterParam = "EntityManagerInViewFilterParam";


    ConfigKey RootApplicationContextConfigClassKey =
            new ConfigKey(RootApplicationContextConfigClass,"",JsonHelper.ClassSet, Collections.emptySet());
    ConfigKey MVCApplicationContextConfigClassKey  =
            new ConfigKey(MVCApplicationContextConfigClass,"",JsonHelper.ClassSet, Collections.emptySet());

    ConfigKey RepositoryScanPackagesKey            =
            new ConfigKey(RepositoryScanPackages,"",JsonHelper.StringSet, Collections.emptySet());
    ConfigKey EntityScanPackagesKey =
            new ConfigKey(EntityScanPackages,"",JsonHelper.StringSet, Collections.emptySet());

    ConfigKey MaxRequestSizeKey                     = new ConfigKey(MaxRequestSize,"",Long.class, 1024*1024*100L);

    ConfigKey ObjectMapperKey                     = new ConfigKey(ObjectMapperRef,"", ObjectMapper.class, JsonHelper.objectMapper());


    ConfigKey DBConfigFileKey = new ConfigKey(DBConfigFile,"",String.class,"db.properties");

    ConfigKey EnableSecuritySupportKey = new ConfigKey(EnableSecuritySupport,"",Boolean.class,Boolean.TRUE);

    ConfigKey EntityManagerInViewFilterParamKey = new ConfigKey(EntityManagerInViewFilterParam,"",String.class,null);


    <T> T readValue(ConfigKey key,Class<T> tClass);

    <T> T readValue(ConfigKey key,JavaType type);

    IConfigValue setupConfigValue(ConfigKey key);

}
